package cn.zhx.xa.bi.dao;

import cn.zhx.xa.bi.mapper.BiChartMapper;
import cn.zhx.xa.model.dto.bi.ChartQueryRequest;
import cn.zhx.xa.model.entity.BiChart;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Component;


@Component
public class BiChartDao extends ServiceImpl<BiChartMapper, BiChart> {


    public Page<BiChart> findByPage(ChartQueryRequest chartQueryRequest, Page<BiChart> page, Long uid) {
        return lambdaQuery()
                .like(StringUtils.isNotBlank(chartQueryRequest.getChartName()), BiChart::getChartName, chartQueryRequest.getChartName())
                .eq(BiChart::getUserId, uid)
                .orderBy(true, false, BiChart::getCreateTime)
                .page(page);
    }

}
